package leetcodecompetition.S116;

import java.util.HashSet;
import java.util.Set;

/**
 * @Author: Siantar
 * @Date: 2023-10-28-23:19
 * @Description: 1.0
 */
public class T100074 {
    public int sumCounts(int[] nums) {
        int n = nums.length, M = 1000000007;
        long res = 0;
        int pre=-1;
        int [] df=new int[n];
        for (int i = 0; i < n; i++) {
            Set<Integer> set = new HashSet<>();
            for (int j = i; j < n; j++) {
                set.add(nums[j]);
                int d = set.size();
                res = ((long) d * d + res) % M;
            }
        }
        return (int) res;
    }

}
